<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>永奥会务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="__CDN__/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__CDN__/css/font.css">
    <link rel="stylesheet" href="__CDN__/css/xadmin.css">
    <script type="text/javascript" src="__CDN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__CDN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__CDN__/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="__CDN__/js/html5.min.js"></script>
      <script src="__CDN__/js/respond.min.js"></script>
    <![endif]-->

      <style>
          .nowrite{
              background-color: #f1efef
          }
      </style>
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form" id="site">

            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input  readonly="readonly" type="hidden" id="uid" name="uid" required="" lay-verify="required"
                            autocomplete="off" class="layui-input nowrite" value="{$siteD->uid}">
                </div>
            </div>

          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>会议名称
              </label>
              <div class="layui-input-inline">
                  <input  readonly="readonly" type="text" id="name" name="name" required="" lay-verify="required"
                  autocomplete="off" class="layui-input nowrite" value="{$siteD->name}">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="domain" class="layui-form-label">
                  <span class="x-red">*</span>站点域名
              </label>

              <div class="layui-input-inline">
                  <input  readonly="readonly" type="text" id="domain" name="domain" required="" lay-verify="required"
                  autocomplete="off" class="layui-input nowrite" value="{$siteD->domain}">
              </div>
          </div>

          <div class="layui-form-item layui-form-text">
              <label for="description" class="layui-form-label">
                  <span class="x-red">*</span>会议描述
              </label>
              <div class="layui-input-block">

                  <textarea      readonly="readonly" placeholder="请输入内容" id="description" name="description" class="layui-textarea nowrite">{$siteD->description}</textarea>
              </div>
          </div>

            <div class="layui-form-item">
                <label class="layui-form-label">站点语言</label>
                <div class="layui-input-block">
                    <?php
                        $arr = $siteD->languages;
                        $data = "zh-CN";
                        $isin = in_array($data,$arr);
                        if($isin){
                            echo '<span  style="white-space:pre;"></span><input class="lan"   type="checkbox" name="languages[]" checked  value="zh-CN" title="中文">';
                        }else{
                            echo '<span  style="white-space:pre;"></span><input class="lan"   type="checkbox" name="languages[]"  value="zh-CN" title="中文">';
                        }
                        $data1 = "en";
                        $isin = in_array($data1,$arr);
                        if($isin){
                            echo '<span  style="white-space:pre;"></span><input class="lan"   type="checkbox" name="languages[]" checked  value="en" title="英文">';
                        }else{
                            echo '<span  style="white-space:pre;"></span><input class="lan"   type="checkbox" name="languages[]"  value="en" title="英文">';
                        }
                    ?>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">站点状态</label>
                <div class="layui-input-inline">
                    <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i><span>{$siteD->app->status_name}</span></div>
                </div>
            </div>

            <div class="layui-form-item">
              <label  class="layui-form-label">
              </label>
              <button id="modify"   class="layui-btn" lay-filter="add" lay-submit="" style="display: none">
                  提交修改
              </button>
              <!--<div id="manage"  class="layui-btn" onclick="top_admin_show('{$siteD->name}','{:url("Conference/index")}')">-->
                    <!--管理站点-->
              <!--</div>-->
            <div id="manage"  class="layui-btn" >
            <a style="color:white" href="{:url("Conference/index")}?site={$siteD->app->client->app_id}" target="_Blank">管理站点</a>
            </div>

              <div id="update"  class="layui-btn">
                    修改站点
               </div>
                <div id="back"  class="layui-btn" style="display: none">
                    返回
                </div>
              <div id="del"  class="layui-btn" lay-filter="del" lay-submit="" style="background-color: #ce3434">
                    撤销站点
              </div>

          </div>

            <div class="layui-form-item">
                <label  class="layui-form-label">
                </label>

            </div>



        </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
              var ss = $('#site').serialize()
              console.log(ss);
            //发异步，把数据提交给php
              $.ajax({
                  dataType : 'json',
                  type : 'POST',
                  url : '{:url("Site/siteUpdate")}',
                  async: false,
                  data : ss,
                  success : function(msg){
                      layer.alert(msg.msg, {icon: 6},function () {
                          layer.closeAll();
                          window.location.reload();
                      });
                  },
                  error : function(XMLHttpRequest, textStatus, errorThrown) {
                      alert(XMLHttpRequest.status + "," + textStatus);
                  }
              });

            return false;
          });
          
          
        });

        //详情页变修改页
        $('#update').click(function(){
            //alert(11);
            $('input').removeAttr("readonly");//去除input元素的readonly属性
            $('textarea[name=description]').removeAttr("readonly");//去除input元素的readonly属性
            $('.lan').removeAttr("disabled");//去除input元素的readonly属性

            $(".layui-input").removeClass("nowrite");//去除框内阴影
            $(".layui-textarea").removeClass("nowrite");

            $("#modify").css("display","");
            $("#back").css("display","");
            $("#update").css("display","none");
            $("#del").css("display","none");
            $("#manage").css("display","none");
        })

        //修改页变详情页
        $('#back').click(function(){
            //alert(11);
            $('input').attr("readonly","readonly");//去除input元素的readonly属性
            $('textarea[name=description]').attr("readonly","readonly");//去除input元素的readonly属性
            $('.lan').attr("disabled");//去除input元素的readonly属性

            $(".layui-input").addClass("nowrite");//去除框内阴影
            $(".layui-textarea").addClass("nowrite");

            $("#modify").css("display","none");
            $("#back").css("display","none");
            $("#update").css("display","");
            $("#del").css("display","");
            $("#manage").css("display","");
        })

        //删除站点
        $('#del').click(function(){
            layui.use('layer', function(){
                layer.confirm('确认删除', {
                    btn: ['是','否'],
                    time: 200000, //20s后自动关闭
                },function(index){

                    var uid = $("#uid").val()
                    //alert("这是点击确定按钮走的回调")
                    $.ajax({
                        dataType : 'json',
                        type : 'POST',
                        url : '{:url("Site/siteDelete")}',
                        async: false,
                        data : {uid:uid},
                        success : function(msg){
                            layer.alert(msg.msg, {icon: 6},function () {
                                layer.closeAll();
                                window.parent.location.reload();
                            });
                        },
                        error : function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest.status + "," + textStatus);
                        }
                    });

                },function(){
                    //这是点击确定按钮走的回调
                    layer.closeAll();

                });
            })
        })

        //站点弹层（弹在最上层）
        function top_admin_show(title,url,w,h) {
            if (title == null || title == '') {
                title=false;
            };
            if (url == null || url == '') {
                url="404.html";
            };
            if (w == null || w == '') {
                w=($(window).width()*1.1);
            };
            if (h == null || h == '') {
                h=($(window).height()*1.1);
            };
            top.layer.open({
                    type: 2,
                    title: title,
                    shadeClose: false,
                    shade: 0.1,
                    fix: false, //不固定
                    area: [w+'px', h +'px'],
                    content: url,
                    maxmin: true,
                    anim: 6,
        });
        }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>